import type { RowType } from '#/views/system/dict/dictItem/dictItem.data';

import { requestClient } from '#/api/request';

export namespace SysDictItemTableApi {
  export type RowTypeFetchParams = RowType;
  export interface IdFetchParams {
    id: string;
  }
  export interface ListFetchParams {
    [key: string]: any;
  }
  export interface PageListFetchParams {
    [key: string]: any;
    pageNo: number;
    pageSize: number;
  }
}

/**
 * 分页列表查询
 */
export async function dictItemQueryPageListApi(
  params: SysDictItemTableApi.PageListFetchParams,
) {
  return requestClient.get('/sys/dictItem/queryPageList', { params });
}

/**
 * 列表查询
 */
export async function dictItemQueryListApi(
  params: SysDictItemTableApi.ListFetchParams,
) {
  return requestClient.get('/sys/dictItem/queryList', { params });
}

/**
 * 通过ID查询
 * @param params
 */
export async function dictItemQueryByIdApi(
  params: SysDictItemTableApi.IdFetchParams,
) {
  return requestClient.get('/sys/dictItem/queryById', { params });
}

/**
 * 新增
 */
export async function dictItemAddApi(
  params: SysDictItemTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/sys/dictItem/add', params);
}

/**
 * 编辑
 */
export async function dictItemEditApi(
  params: SysDictItemTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/sys/dictItem/edit', params);
}

/**
 * 删除
 * @param id 主键
 */
export async function dictItemDelApi(id) {
  return requestClient.delete<boolean>(`/sys/dictItem/delete/${id}`);
}

/**
 * 批量删除删除
 * @param ids 主键
 */
export async function dictItemDeleteBatchApi(ids) {
  return requestClient.delete<boolean>(`/sys/dictItem/deleteBatchByIds/${ids}`);
}
